import request from 'umi-request';

// 用户
export async function fetchUserList(params = {}) {
  return request('/amaidan-sys-user/merchants/user/list', {
    method: 'POST',
    data: params,
  });
}

export async function deleteUser(params = {}) {
  return request('/amaidan-sys-user/merchants/user/delete', {
    method: 'POST',
    data: params,
  });
}

export async function saveOrUpdateUser(params = {}) {
  return request('/amaidan-sys-user/merchants/user/saveOrUpdate', {
    method: 'POST',
    data: params,
  });
}

// 用户关联角色
// 分配
export async function assignMutipleRoles(params = {}) {
  return request('/amaidan-sys-user/merchants/user/batchUpdateUserRoleRef', {
    method: 'POST',
    data: params,
  });
}

// 查询
export async function getRolesByUserId(params = {}) {
  return request('/amaidan-sys-user/merchants/role/listRolesByUserId', {
    method: 'POST',
    data: params,
  });
}

export async function assignRole(params = {}) {
  return request('/amaidan-sys-user/merchants/user/saveUserRoleRef', {
    method: 'POST',
    data: params,
  });
}

export async function deleteRole(params = {}) {
  return request('/amaidan-sys-user/merchants/user/delUserRoleRef', {
    method: 'POST',
    data: params,
  });
}

// 角色权限关联
// 查询
export async function fetchPermissionsByRoleId(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/listPermissionsByRoleId', {
    method: 'POST',
    data: params,
  });
}
// 分配
export async function assignPermissionsByRole(params = {}) {
  return request('/amaidan-sys-user/merchants/role/batchRolePermissionRef', {
    method: 'POST',
    data: params,
  });
}

// 权限
export async function fetchPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/list', {
    method: 'POST',
    data: params,
  });
}

export async function saveOrUpdatePermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/saveOrUpdate', {
    method: 'POST',
    data: params,
  });
}

export async function deletePermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/delete', {
    method: 'POST',
    data: params,
  });
}
// 查询单个权限
export async function getOnePermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/get', {
    method: 'POST',
    data: params,
  });
}

// 菜单权限
export async function getMenuByPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/menu/getMenuByPermission', {
    method: 'POST',
    data: params,
  });
}
export async function addMenuPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/saveSysPermissionMenuRef', {
    method: 'POST',
    data: params,
  });
}
export async function delMenuPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/delSysPermissionMenuRef', {
    method: 'POST',
    data: params,
  });
}
// 按钮权限
export async function getBtnByPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/element/getElementByPermission', {
    method: 'POST',
    data: params,
  });
}
export async function addBtnPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/saveSysPermissionElementRef', {
    method: 'POST',
    data: params,
  });
}
export async function delBtnPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/delSysPermissionElementRef', {
    method: 'POST',
    data: params,
  });
}

// 功能权限
export async function addOperatePermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/saveSysPermissionOperationRef', {
    method: 'POST',
    data: params,
  });
}

export async function getOperateByPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/operation/getElementByPermission', {
    method: 'POST',
    data: params,
  });
}
export async function delOperateByPermission(params = {}) {
  return request('/amaidan-sys-user/merchants/permission/delSysPermissionOperationRef', {
    method: 'POST',
    data: params,
  });
}
// 功能
export async function fetchOperationList(params = {}) {
  return request('/amaidan-sys-user/merchants/operation/list', {
    method: 'POST',
    data: params,
  });
}

export async function saveOrUpdateOperation(params = {}) {
  return request('/amaidan-sys-user/merchants/operation/saveOrUpdate', {
    method: 'POST',
    data: params,
  });
}

export async function deleteOperation(params = {}) {
  return request('/amaidan-sys-user/merchants/operation/delete', {
    method: 'POST',
    data: params,
  });
}

export async function getOneOperate(params = {}) {
  return request('/amaidan-sys-user/merchants/operation/get', {
    method: 'POST',
    data: params,
  });
}